package com.demo.connectdbtest.module.price.popoMapper;

import com.demo.connectdbtest.module.dict.domain.StatGoldConsumeStatistics;
import com.demo.connectdbtest.module.price.domain.Price;
import com.demo.connectdbtest.module.price.vo.AddPriceVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.data.mongodb.core.aggregation.ArrayOperators;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

//@Mapper
public interface PriceMapper {

    Price getNumberScale();

    List<BigDecimal> getAllPrice();

    @Select("<script>"+
            "select id, uid, uuid, total_consume_gold, create_time, update_time from stat_gold_consume_statistics where uid in " +
            "<foreach collection = 'list' item = 'uid' open = '(' close = ')' separator = ','>" +
            "#{uid}"+
            "</foreach>" +
            "</script>")
    List<StatGoldConsumeStatistics> listConsumeRecordByBatchUid(@Param("list") List<Long> uidList);

    void batchUpdate(@Param("list") ArrayList<Price> prices);

    @Update("update price set price = #{price} where id = #{id}")
    void updatePrice(@Param("id") Integer id, @Param("price")BigDecimal price);

//    @Insert("insert into price(price,number) values(#{price},#{number})")
//    @Options(useGeneratedKeys = true,keyColumn = "id", keyProperty = "id")
//    void addPrice(@Param("price")BigDecimal price,@Param("number") Integer number);

    @Delete("delete from price where id = #{id}")
    void deletePrice(@Param("id")Integer id);


    @Insert("insert into price(price,number) values(#{price},#{number})")
    @Options(useGeneratedKeys = true,keyColumn = "id", keyProperty = "id")
    void addPrice(AddPriceVo vo);
}
